<template>
  <div class="container" @click="handleGalleryClick">
      <swiper :options="swiperOption">
        <!-- slides -->
        <swiper-slide v-for="(item, index) of imgs" :key="index">
          <div class="gallery-bgImg" :style="{backgroundImage: 'url(' + item + ')'}"></div>
        </swiper-slide>
        <!-- Optional controls -->
        <div class="swiper-pagination"  slot="pagination"></div>
      </swiper>
  </div>
</template>

<script>
export default {
  name: 'CommonGallery',
  props: {
    imgs: {
      type: Array,
      default () {
        return []
      }
    }
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination',
        paginationType: 'fraction',
        observer: true,
        observeParents: true
      }
    }
  },
  methods: {
    handleGalleryClick () {
      this.$emit('close')
    }
  }
}
</script>

<style lang="stylus" scoped>
.container >>> .swiper-container
  width 100%
  height: 100%
  color #fff
  overflow: inherit
.container >>> .swiper-wrapper
  align-items:center
.container
  display: flex
  flex-direction: column
  justify-content: center
  position: fixed
  left:0
  right:0
  top:0
  bottom: 0
  background #000
  z-index: 99
  .gallery-bgImg
    height: 100%
    background-size contain
    background-repeat no-repeat
    background-position center
  .swiper-pagination
    bottom:.4rem
</style>
